package com.qf.zuoye0612.controller;

import com.qf.zuoye0612.tools.Name;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @Author UNIQ7xi
 * @Date 2023/6/12 17:18
 * @Version v1.8
 **/

@RestController
@RequestMapping("/name")
public class NameController {

    @GetMapping("/point")
    public String Point(Boolean name){
        List<String> list = Name.AllName();
        int index = 0;
        if (name){
            index = new Random().nextInt(list.size());
        }else {
            if (list.isEmpty()) return "都已经点过啦!!!";
            index = new Random().nextInt(list.size());
            String remove = list.remove(index);
            return String.format("点名结果：%s", remove);
        }
        String s = list.get(index);
        return String.format("点名结果:%s",s);
    }

    @GetMapping("/reset")
    public String reset(){
        List<String> list = Name.AllName();
        list.clear();
        list.addAll(Arrays.asList("白兆爽","曹彧宁","陈亮","陈永生","范雅罡",
                "冯弥群","冯名轩","李国庆","李双跃","李汪洋","刘海鹏",
                "刘毅","刘宇琦","刘正杰","罗嘉兴","罗锦","罗鑫鹏","吕品喜",
                "戚晓东","邱贝宁","苏宝椿","佟强","汪俏","王健磊","王铭浩",
                "王宇鹏","吴昊卿","闫朋文泽","杨立","杨守靖","袁铭","张力元",
                "张云翔","张子豪","赵凌轩","赵振","郑晰文"));
        return "已经重置";
    }
}
